package com.ali.aliwebsite.controller;

import com.ali.aliwebsite.entity.Admin;
import com.ali.aliwebsite.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AdminController {
    @Autowired
    AdminMapper adminMapper;

    @RequestMapping("admin/admin/login")
    public int login(@RequestBody Admin admin) {
        //1、调用mapper中的方法进行数据库信息比对
        String pwd = adminMapper.login(admin.getUsername());
        //2、对数据库返回信息做处理
        if (pwd == null) {
            return 1;//用户名不存在
        }
        if (pwd.equals(admin.getPassword())) {
            return 2;//登录成功
        }
        return 3;//密码错误
    }
}
